<?php
session_start();
(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))?ob_start('ob_gzhandler'):ob_start();
header('Content-type: text/html; charset=utf-8');

require_once('config.php');
require_once('lib/autoload.php');

$route = new handle_route();
$_md = new system_model();
$admin_lang = $_md->model_get_lang('DefaultAdmin');
$public_lang = $_md->model_get_lang('DefaultPublic');
$seokey = array();
$seokey = $route->rt_get_all_val_seo();

$_SESSION['dir_lang'] = empty($seokey[0])?$public_lang['DirName']:$admin_lang['DirName'];

define('LANG',(empty($seokey[0])?$public_lang['ID']:$admin_lang['ID']),true);

define('DIR_LANG_ADMIN_DEFAULT',$admin_lang['DirName'], true );
define('DIR_LANG_PUBLIC_DEFAULT',$public_lang['DirName'], true );
define('DIR_LANG_DEFAULT',(empty($seokey[0])?$public_lang['DirName']:$admin_lang['DirName']),true);
define('SEO_DEFAULT'        ,$_md->model_get_app_seokey(DIR_DEFAULT)    ,true);
define('SEO_ADMIN'          ,$_md->model_get_app_seokey(DIR_ADMIN)      ,true);
define('APP_CURRENT'        ,$_md->model_get_app( isset($seokey[0])?$seokey[0]:'' ), true );
define('SEO_CURRENT'        ,$_md->model_get_app_seokey(APP_CURRENT), true );
define('PATH_LANGUAGE'      ,PATH_APP.APP_CURRENT.'/view/'.DIR_LANG.'/'.DIR_LANG_DEFAULT,true);
define('PATH_TEMPLATE'      ,PATH_APP.APP_CURRENT.'/view/'.DIR_TEMP.'/'.DIR_TEMP_PUBLIC_DEFAULT,true);
define('URL_TEMPLATE'       ,URL_BASE.DIR_APP.'/'.APP_CURRENT.'/view/'.DIR_TEMP.'/'.DIR_TEMP_PUBLIC_DEFAULT,true);
define('PATH_APPLICATION'   ,PATH_APP.APP_CURRENT.'/',true);


$ctr = new system_controller();
$ctr->route = $route;
$ctr->model = $_md;
$ctr->_seokey = $seokey;

print($ctr->index_action());


ob_end_flush();